package com.baosu.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baosu.domain.Result;
import com.baosu.domain.Tag;
import com.baosu.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/front/tag")
@Api(tags = "标签接口-前台")
public class TagFrontController {

    @Autowired
    private TagService tagService;

    @GetMapping("/getByArtucleId/{id}")
    @ApiOperation(value = "根据文章ID查询标签列表")
    public Result getByArticleId(@PathVariable Long id){
        return tagService.getByArtucleId(id);
    }

    @GetMapping("/list")
    @ApiOperation(value = "获取所有标签以及关联文章总数")
    public Result<List> getArticleCount(){
       return tagService.getArticleCount();
    }

    @GetMapping("/getArticleByTag")
    @ApiOperation(value = "根据标签ID查询文章列表")
    public Result getArticleByTag(int pagenum, int pagesize,Long id){
        return tagService.getArticleByTag(pagenum,pagesize,id);
    }


}
